#define _DATAFLASH_MAP_C_
/* Includes ---------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "DataFlashMap.h"
/* USER CODE END Includes */
/* Macro ------------------------------------------------------------*/
/* USER CODE BEGIN Macro */
#define DATA_FLASH_VERSION                                      (0x02)

#define DATA_FLASH_START_ADDR                                   (0x0001C000UL)
#define DATA_FLASH_END_ADDR                                     (0x0001FFFFUL)

#define PAGE_SIZE                                               (512)

#define DATA_FLASH_PAGE0                                        (DATA_FLASH_START_ADDR)
#define DATA_FLASH_PAGE1                                        (DATA_FLASH_PAGE0 + PAGE_SIZE)
#define DATA_FLASH_PAGE2                                        (DATA_FLASH_PAGE1 + PAGE_SIZE)
#define DATA_FLASH_PAGE3                                        (DATA_FLASH_PAGE2 + PAGE_SIZE)

#define DATA_FLASH_VER_ADDR                                     (DATA_FLASH_START_ADDR)
/* USER CODE END Macro */
/* Types ------------------------------------------------------------*/
/* USER CODE BEGIN Types */
enum DataFlashMap
{
	// System Data
	eDataFlash_SystemData = DATA_FLASH_START_ADDR,
	eDataFlash_Version = eDataFlash_SystemData,
	
	// Command #0 Read Unique Identifier
	eDataFlash_UniqueID = eDataFlash_SystemData + 0x04,
	eDataFlash_Byte0 = eDataFlash_UniqueID,
	eDataFlash_Expand_Dev_Type, // 2bytes
	eDataFlash_Mini_Preambles_For_Request = eDataFlash_Expand_Dev_Type + 2,
	
	eDataFlash_Hart_Major_Rev,
	eDataFlash_Dev_Rev_Level,
	eDataFlash_Software_Rev,
	eDataFlash_Hart_Rev_And_Phy_Sig,
	
	eDataFlash_Flags,
	eDataFlash_Device_ID, // 3bytes
	
	eDataFlash_Mini_Preambles_For_Reaponse = eDataFlash_Device_ID + 3,
	eDataFlash_Max_Device_Variables,
	eDataFlash_Config_Change_Counter, // 2bytes
	
	eDataFlash_Ext_Field_Dev_Status = eDataFlash_Config_Change_Counter + 2,
	eDataFlash_Manufacturer_ID,
	eDataFlash_Reserved0 = eDataFlash_Manufacturer_ID + 2,
	
	eEEPROM_Private_Lab_Distributor_Code, // 2bytes
	eEEPROM_Device_Profile = eEEPROM_Private_Lab_Distributor_Code + 2,
	// reserved,
	
	// Command #1#3 Variables Unit
	eDataFlash_Variables_Unit = eDataFlash_UniqueID + 24,
	eDataFlash_PV_Unit = eDataFlash_Variables_Unit,
	eDataFlash_SV_Unit,
	eDataFlash_TV_Unit,
	eDataFlash_QV_Unit,
	// Command #6#7 Loop Configuration
	eDataFlash_Loop_Configuration = eDataFlash_Variables_Unit + 4,
	eDataFlash_Polling_Addr = eDataFlash_Loop_Configuration,
	eDataFlash_Loop_Current_Mode,
	// reserved[2]
	
	// Command #8 Dynamic Variable Classification
	eDataFlash_Dynamic_Variable_Cls = eDataFlash_Loop_Configuration + 4,
	eDataFlash_PV_Classification = eDataFlash_Dynamic_Variable_Cls,
	eDataFlash_SV_Classification,
	eDataFlash_TV_Classification,
	eDataFlash_QV_Classification,
	
	// Command #12 Device Message
	eDataFlash_Device_Msg = eDataFlash_Dynamic_Variable_Cls + 4, // 24bytes
	
	// Command #13 Tag,Descriptor,Date
	eDataFlash_Device_Tag = eDataFlash_Device_Msg + 24,
	// reserved[2]
	
	eDataFlash_Device_Descriptor = eDataFlash_Device_Tag + 8,
	
	eDataFlash_Device_Date = eDataFlash_Device_Descriptor + 12,
	// reserved[1]
	
	// Command #14 Primary Variable Transducer Information
	eDataFlash_Transducer_SN = eDataFlash_Device_Date + 4,
	eDataFlash_TransLimit_And_MinSpanUnit = eDataFlash_Transducer_SN + 4,
	eDataFlash_Upper_Transducer_Limit = eDataFlash_TransLimit_And_MinSpanUnit + 4,
	eDataFlash_Lower_Transducer_Limit = eDataFlash_Upper_Transducer_Limit + 4,
	eDataFlash_Minimum_Span = eDataFlash_Lower_Transducer_Limit + 4,
	
	// Command #15 Device Information
	eDataFlash_PV_Information = eDataFlash_Minimum_Span + 4,
	eDataFlash_PV_Alarm_Sel_Code = eDataFlash_PV_Information,
	eDataFlash_PV_Transfer_Func_Code,
	eDataFlash_PV_UpperLower_Range_Units_Code,
	// reserved
	
	eDataFlash_PV_Upper_Range_Value = eDataFlash_PV_Alarm_Sel_Code + 4,
	eDataFlash_PV_Lower_Range_Value = eDataFlash_PV_Upper_Range_Value + 4,
	eDataFlash_PV_Damping_Value = eDataFlash_PV_Lower_Range_Value + 4,
	eDataFlash_Write_Protect_Code = eDataFlash_PV_Damping_Value + 4,
	// reserved 250
	eDataFlash_PV_Analog_Channel_Flags = eDataFlash_Write_Protect_Code + 2,
	// reserved
	
};

typedef struct
{
	uint8_t ucDataFlashVer;
	uint8_t ucReserved[3];
}STSysData;

/* USER CODE END Types */

/* Constants --------------------------------------------------------*/
/* USER CODE BEGIN Constants */

/* USER CODE END Constants */

/* Variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */
STSysData stSysData;

STSysData stSysDataDefault = 
{
	DATA_FLASH_VERSION,
	0x01,
	0x02,
	0x03,
};
// Command #0
STHartReadUniqueIdentifierRes stReadUniqueIdResDefault = 
{
	0xfe, // byte0
	5, // byte3, Minimum number of Preambles required for the request mesage
	0x82E2, // byte1~2, Expanded Device Type
	
	0x07, // byte4, HART Protocol Major Revision
	0x07, // byte5, Device Revision Level
	0x02, // byte6, Software Revision
	(0x02 << 3) | eBELL202_CURRENT, // byte7: bit3~7, Hardware Revision; bit0~2, Physical Signaling Code
	
	0x742E96, // byte9~11, Device ID
	
	eEEPROM_CTL, // byte8, Flags
	0x02, // byte12, Minimum number of Preambles for the resoonse message
	0x07, // byte13, Maximum Number of Device Variables
	eMAIN_REQUIRED, // byte16, Extended Field Device Status
	
	0x1234, // byte14~15, Configuration Change Counter
	0x5678, // byte17~18, Manufacturer Identification Code
	
	0x0001, // byte19~20, Private Label Distributor Code
	eHART_PROCESS_AUTO_DEV, // byte21, Device Profile
	0x00, // reserved
};
// Command #1#3
STHartVariableUnit stVariablesUnitDefault =
{
	ePRESSURE_TORR,
	ePRESSURE_KILOPASCALS,
	ePRESSURE_KILOPASCALS,
	ePRESSURE_KILOPASCALS,
};
// Command #6#7
STHartLoopConfig stLoopConfigDefault = 
{
	0x00,
	0x01, //eLOOP_CURRENT_MODE_ENABLE,
	{0x00, 0x00},
};
// Command #8
STDynamicVariableCls stDynamicVariableClsDefault = 
{
	eTB21Pressure, // Pressure
	eTB21Temperature, // Temperature
	eTB21DeviceVariableNotClassified, // Not Used
	eTB21DeviceVariableNotClassified, // Not Used
};
// Command #12 Device Message
STHartDeviceMsg stDeviceMsgDefault = 
{
	{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23}
};
// Command #13 Tag, Descriptor, Date
STHartTagDescriptorDate stHartTagDescriptorDateDefault = 
{
	// Tag
	{0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, 
	{0x00, 0x00}, // reserved
	// Descriptor
	{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC},
	// Date
	{0x11, 0x22, 0x33},
};
// Command #14 Primary Variable Transducer Information
STHartPrimaryVarTransInfo stPVTransducerInfoDefault = 
{
	0x1E240,
	ePRESSURE_KILOPASCALS,
	{0x00, 0x00, 0x00},
	2.5f,
	0.0f,
	0.1f,
};
// Command #15 Device Information
STDeviceInfo stDeviceInfoDefault = 
{
	eALARM_SEL_LOW,
	eTRANSFER_FUNC_SQUARE_ROOT,
	ePRESSURE_KILOPASCALS,
	0x00,
	
	2.5f,
	0.0f,
	0.1f,
	
	eWRITE_PRO_WRITE_PROTECTED,
	250,
	0x01,
	0x00,
};
/* USER CODE END Variables */

/* Function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FP */
// Command 0 Read Unique Identifier
static void vUniqueIdentifierLoadData(void);
// Command #1#3 Variables Unit
static void vVariablesUnitLoadData(void);
// Command #6#7
static void vLoopConfigurationLoadData(void);
// Command #8
static void vDynamicVariableClassificationLoadData(void);
// Command #12 Device Message
static void vDeviceMessageLoadData(void);
// Command #13 Tag, Descriptor, Date
static void vTagDescriptorDateLoadData(void);
// Command #14 Primary Variable Transducer Information
static void vPrimaryVariableTransducerInfoLoadData(void);
// Command #15 Device Information
static void vDeviceInformationLoadData(void);
/* USER CODE END FP */
/**
  * @brief  @
  * @param  @
  * @retval @
  */
void vDataFlashPowerOnLoadData(void)
{
//	uint8_t const * const pDataFlahVer = (uint8_t *)eDataFlash_Version; 
//	
//	if((*pDataFlahVer) == 0xff)
//	{
//		vSystemSetup();
//	}
	
	// Command 0 Read Unique Identifier
	vUniqueIdentifierLoadData();
	// Command #1#3 Variables Unit
	vVariablesUnitLoadData();
	// Command #6#7
	vLoopConfigurationLoadData();
	// Command #8
	vDynamicVariableClassificationLoadData();
	// Command #12 Device Message
	vDeviceMessageLoadData();
	// Command #13 Tag, Descriptor, Date
	vTagDescriptorDateLoadData();
	// Command #14 Primary Variable Transducer Information
	vPrimaryVariableTransducerInfoLoadData();
	// Command #15 Device Information
	vDeviceInformationLoadData();
}
/**
  * @brief  @
  * @param  @
  * @retval @
  */
void vSystemSetup(void)
{	
	FL_FLASH_PageErase(FLASH, DATA_FLASH_PAGE0);
	
	// System Data
	for(uint8_t i = 0; i < (sizeof(stSysDataDefault) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_SystemData + (4 * i), *((uint32_t *)(((uint8_t *)&stSysDataDefault) + 4 * i)));
	}
	memcpy((uint8_t *)&stSysData, (uint8_t *)&stSysDataDefault, sizeof(stSysDataDefault));
	
	// Command 0 Read Unique Identifier
	for(uint8_t i = 0; i < (sizeof(stReadUniqueIdResDefault) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_UniqueID + (4 * i), *((uint32_t *)(((uint8_t *)&stReadUniqueIdResDefault) + 4 * i)));
	}
	memcpy((uint8_t *)&stReadUniqueIdRes, (uint8_t *)&stReadUniqueIdResDefault, sizeof(stReadUniqueIdResDefault));
	
	// Command #1#3 Variables Unit
	FL_FLASH_Program_Word(FLASH, eDataFlash_Variables_Unit, *((uint32_t *)((uint8_t *)&stVariablesUnitDefault)));
	memcpy((uint8_t *)&stVariablesUnit, (uint8_t *)&stVariablesUnitDefault, sizeof(stVariablesUnitDefault));
	
	// Command #6#7
	FL_FLASH_Program_Word(FLASH, eDataFlash_Loop_Configuration, *((uint32_t *)((uint8_t *)&stLoopConfigDefault)));
	memcpy((uint8_t *)&stLoopConfig, (uint8_t *)&stLoopConfigDefault, sizeof(stLoopConfig));
	
	// Command #8
	FL_FLASH_Program_Word(FLASH, eDataFlash_Dynamic_Variable_Cls, *((uint32_t *)((uint8_t *)&stDynamicVariableClsDefault)));
	memcpy((uint8_t *)&stDynamicVariableCls, (uint8_t *)&stDynamicVariableClsDefault, sizeof(stDynamicVariableCls));
	
	// Command #12 Device Message
	for(uint8_t i = 0; i < (sizeof(stDeviceMsgDefault) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Msg + (4 * i), *((uint32_t *)(((uint8_t *)&stDeviceMsgDefault) + 4 * i)));
	}
	memcpy((uint8_t *)&stDeviceMsg, (uint8_t *)&stDeviceMsgDefault, sizeof(stDeviceMsg));
	
	// Command #13 Tag, Descriptor, Date
	// Tag
	for(uint8_t i = 0; i < 2; i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Tag + (4 * i), *((uint32_t *)(((uint8_t *)&stHartTagDescriptorDateDefault.ucTag) + 4 * i)));
	}
	memcpy((uint8_t *)&stHartTagDescriptorDate.ucTag, (uint8_t *)&stHartTagDescriptorDateDefault.ucTag, 6);
	// Descriptor
	for(uint8_t i = 0; i < 3; i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Descriptor + (4 * i), *((uint32_t *)(((uint8_t *)&stHartTagDescriptorDateDefault.ucDescriptor) + 4 * i)));
	}
	memcpy((uint8_t *)&stHartTagDescriptorDate.ucDescriptor, (uint8_t *)&stHartTagDescriptorDateDefault.ucDescriptor, 12);
	// Date
	FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Date, *((uint32_t *)((uint8_t *)&stHartTagDescriptorDateDefault.ucDate)));
	memcpy((uint8_t *)&stHartTagDescriptorDate.ucDate, (uint8_t *)&stHartTagDescriptorDateDefault.ucDate, 3);
	
	// Command #14 Primary Variable Transducer Information
	// Transducer Serial Number
	FL_FLASH_Program_Word(FLASH, eDataFlash_Transducer_SN, *((uint32_t *)((uint8_t *)&stPVTransducerInfoDefault.ulTransSN)));
	memcpy((uint8_t *)&stPVTransducerInfo.ulTransSN, (uint8_t *)&stPVTransducerInfoDefault.ulTransSN, 3);
	// Transducer Limits and Minimum Span Units Code
	FL_FLASH_Program_Word(FLASH, eDataFlash_TransLimit_And_MinSpanUnit, *((uint32_t *)((uint8_t *)&stPVTransducerInfoDefault.eTransLimAndMiniSpanUnitCode)));
	stPVTransducerInfo.eTransLimAndMiniSpanUnitCode = stPVTransducerInfoDefault.eTransLimAndMiniSpanUnitCode;
	// Upper Transducer Limit
	FL_FLASH_Program_Word(FLASH, eDataFlash_Upper_Transducer_Limit, *((uint32_t *)((uint8_t *)&stPVTransducerInfoDefault.fUpperTransLimit)));
	stPVTransducerInfo.fUpperTransLimit = stPVTransducerInfoDefault.fUpperTransLimit;
	// Lower Transducer Limit
	FL_FLASH_Program_Word(FLASH, eDataFlash_Lower_Transducer_Limit, *((uint32_t *)((uint8_t *)&stPVTransducerInfoDefault.fLowerTransLimit)));
	stPVTransducerInfo.fLowerTransLimit = stPVTransducerInfoDefault.fLowerTransLimit;
	// Minimum Span
	FL_FLASH_Program_Word(FLASH, eDataFlash_Minimum_Span, *((uint32_t *)((uint8_t *)&stPVTransducerInfoDefault.fMiniSpan)));
	stPVTransducerInfo.fMiniSpan = stPVTransducerInfoDefault.fMiniSpan;
	
	// Command #15 Device Information
	for(uint8_t i = 0; i < (sizeof(stDeviceInfoDefault) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_PV_Information + (i * 4), *((uint32_t *)(((uint8_t *)&stDeviceInfoDefault.ePVAlarmSelCode) + 4 * i)));
	}
	memcpy((uint8_t *)&stDeviceInfo.ePVAlarmSelCode, (uint8_t *)&stDeviceInfoDefault.ePVAlarmSelCode, sizeof(stDeviceInfoDefault));
}
/**
  * @brief  @
  * @param  @
  * @retval @
  */
void vDataFlashSaveModifiedData(void)
{	
	FL_FLASH_PageErase(FLASH, DATA_FLASH_PAGE0);
	
	// System Data
	for(uint8_t i = 0; i < (sizeof(stSysDataDefault) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_SystemData + (4 * i), *((uint32_t *)(((uint8_t *)&stSysData) + 4 * i)));
	}
	
	// Command 0 Read Unique Identifier
	for(uint8_t i = 0; i < (sizeof(stReadUniqueIdRes) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_UniqueID + (4 * i), *((uint32_t *)(((uint8_t *)&stReadUniqueIdRes) + 4 * i)));
	}
	
	// Command #1#3 Variables Unit
	FL_FLASH_Program_Word(FLASH, eDataFlash_Variables_Unit, *((uint32_t *)((uint8_t *)&stVariablesUnit)));
	
	// Command #6#7 Loop Configuration
	FL_FLASH_Program_Word(FLASH, eDataFlash_Loop_Configuration, *((uint32_t *)((uint8_t *)&stLoopConfig)));
	
	// Command #8
	FL_FLASH_Program_Word(FLASH, eDataFlash_Dynamic_Variable_Cls, *((uint32_t *)((uint8_t *)&stDynamicVariableCls)));
	
	// Command #12 Device Message
	for(uint8_t i = 0; i < (sizeof(stDeviceMsg) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Msg + (4 * i), *((uint32_t *)(((uint8_t *)&stDeviceMsg) + 4 * i)));
	}
	
	// Command #13 Tag, Descriptor, Date
	// Tag
	for(uint8_t i = 0; i < 2; i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Tag + (4 * i), *((uint32_t *)(((uint8_t *)&stHartTagDescriptorDate.ucTag) + 4 * i)));
	}
	// Descriptor
	for(uint8_t i = 0; i < 3; i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Descriptor + (4 * i), *((uint32_t *)(((uint8_t *)&stHartTagDescriptorDate.ucDescriptor) + 4 * i)));
	}
	// Date
	FL_FLASH_Program_Word(FLASH, eDataFlash_Device_Date, *((uint32_t *)((uint8_t *)&stHartTagDescriptorDate.ucDate)));
	
	// Command #14 Primary Variable Transducer Information
	// Transducer Serial Number
	FL_FLASH_Program_Word(FLASH, eDataFlash_Transducer_SN, *((uint32_t *)((uint8_t *)&stPVTransducerInfo.ulTransSN)));
	// Transducer Limits and Minimum Span Units Code
	FL_FLASH_Program_Word(FLASH, eDataFlash_TransLimit_And_MinSpanUnit, *((uint32_t *)((uint8_t *)&stPVTransducerInfo.eTransLimAndMiniSpanUnitCode)));
	// Upper Transducer Limit
	FL_FLASH_Program_Word(FLASH, eDataFlash_Upper_Transducer_Limit, *((uint32_t *)((uint8_t *)&stPVTransducerInfo.fUpperTransLimit)));
	// Lower Transducer Limit
	FL_FLASH_Program_Word(FLASH, eDataFlash_Lower_Transducer_Limit, *((uint32_t *)((uint8_t *)&stPVTransducerInfo.fLowerTransLimit)));
	// Minimum Span
	FL_FLASH_Program_Word(FLASH, eDataFlash_Minimum_Span, *((uint32_t *)((uint8_t *)&stPVTransducerInfo.fMiniSpan)));
	
	// Command #15 Device Information
	for(uint8_t i = 0; i < (sizeof(stDeviceInfo) / 4); i++)
	{
		FL_FLASH_Program_Word(FLASH, eDataFlash_PV_Information + (i * 4), *((uint32_t *)(((uint8_t *)&stDeviceInfo.ePVAlarmSelCode) + 4 * i)));
	}
}
/**
  * @brief  Command #0
  * @param  @
  * @retval @
  */
static void vUniqueIdentifierLoadData(void)
{
	uint8_t * const pData = (uint8_t *)&stReadUniqueIdRes;
	
	for(uint8_t i = 0; i < sizeof(stReadUniqueIdResDefault); i++)
	{
		*(pData + i) = *(((uint8_t *)eDataFlash_Byte0) + i);
	}
}
/**
  * @brief  Command #1#3
  * @param  @
  * @retval @
  */
static void vVariablesUnitLoadData(void)
{
	stVariablesUnit.ePVUnit = (EnumEngineeringUnitCode)(*((uint8_t *)eDataFlash_PV_Unit));
	stVariablesUnit.eSVUnit = (EnumEngineeringUnitCode)(*((uint8_t *)eDataFlash_SV_Unit));
	stVariablesUnit.eTVUnit = (EnumEngineeringUnitCode)(*((uint8_t *)eDataFlash_TV_Unit));
	stVariablesUnit.eQVUnit = (EnumEngineeringUnitCode)(*((uint8_t *)eDataFlash_QV_Unit));
}
/**
  * @brief  Command #6#7
  * @param  @
  * @retval @
  */
static void vLoopConfigurationLoadData(void)
{
	stLoopConfig.ucPollingAddr = *((uint8_t *)eDataFlash_Polling_Addr);
	stLoopConfig.eLoopCurMode = (EnumLoopCurrentModeCode)(*((uint8_t *)eDataFlash_Loop_Current_Mode));
}
/**
  * @brief  Command #8
  * @param  @
  * @retval @
  */
static void vDynamicVariableClassificationLoadData(void)
{
	stDynamicVariableCls.ucPVCls = (EnumDevVariableClsCode)(*((uint8_t *)eDataFlash_PV_Classification));
	stDynamicVariableCls.ucSVCls = (EnumDevVariableClsCode)(*((uint8_t *)eDataFlash_SV_Classification));
	stDynamicVariableCls.ucTVCls = (EnumDevVariableClsCode)(*((uint8_t *)eDataFlash_TV_Classification));
	stDynamicVariableCls.ucQVCls = (EnumDevVariableClsCode)(*((uint8_t *)eDataFlash_QV_Classification));
}
/**
  * @brief  Command #12
  * @param  @
  * @retval @
  */
static void vDeviceMessageLoadData(void)
{
	for(uint8_t i = 0; i < 24; i++)
	{
		stDeviceMsg.ucMsg[i] = *((uint8_t *)eDataFlash_Device_Msg + i);
	}
}
/**
  * @brief  Command #13 Tag, Descriptor, Date
  * @param  @
  * @retval @
  */
static void vTagDescriptorDateLoadData(void)
{
	// Tag
	for(uint8_t i = 0; i < 6; i++)
	{
		stHartTagDescriptorDate.ucTag[i] = *((uint8_t *)eDataFlash_Device_Tag + i);
	}
	// Descriptor
	for(uint8_t i = 0; i < 12; i++)
	{
		stHartTagDescriptorDate.ucDescriptor[i] = *((uint8_t *)eDataFlash_Device_Descriptor + i);
	}
	// Date
	for(uint8_t i = 0; i < 3; i++)
	{
		stHartTagDescriptorDate.ucDate[i] = *((uint8_t *)eDataFlash_Device_Date + i);
	}
}
/**
  * @brief  Command #15 Device Information
  * @param  @
  * @retval @
  */
static void vPrimaryVariableTransducerInfoLoadData(void)
{
	stPVTransducerInfo.ulTransSN = *((uint32_t *)eDataFlash_Transducer_SN);
	stPVTransducerInfo.eTransLimAndMiniSpanUnitCode = (EnumEngineeringUnitCode)(*((uint8_t *)eDataFlash_TransLimit_And_MinSpanUnit));
	stPVTransducerInfo.fUpperTransLimit = *((float *)eDataFlash_Upper_Transducer_Limit);
	stPVTransducerInfo.fLowerTransLimit = *((float *)eDataFlash_Lower_Transducer_Limit);
	stPVTransducerInfo.fMiniSpan = *((float *)eDataFlash_Minimum_Span);
}
static void vDeviceInformationLoadData(void)
{
	stDeviceInfo.ePVAlarmSelCode = (EnumAlarmSelCode)(*((uint8_t *)eDataFlash_PV_Alarm_Sel_Code));
	stDeviceInfo.ePVTransFunCode = (EnumTransferFuncCode)(*((uint8_t *)eDataFlash_PV_Transfer_Func_Code));
	stDeviceInfo.ePVUpLowRangeValUnitCode = (EnumEngineeringUnitCode)(*((uint8_t *)eDataFlash_PV_UpperLower_Range_Units_Code));
	stDeviceInfo.fPVUpperRangeVal = *((float *)eDataFlash_PV_Upper_Range_Value);
	stDeviceInfo.fPVLowerRangeVal = *((float *)eDataFlash_PV_Lower_Range_Value);
	stDeviceInfo.fPVDampingVal = *((float *)eDataFlash_PV_Damping_Value);
	stDeviceInfo.eWriteProtectCode = *((uint8_t *)eDataFlash_Write_Protect_Code);
	stDeviceInfo.ucPVAnalogChgFlgs = *((uint8_t *)eDataFlash_PV_Analog_Channel_Flags);
}
